/**
 * Created by fangshufeng on 2017/12/27.
 */

import {Modal} from 'antd'

const confirm = Modal.confirm;

export let ErrorModal = function (title = '提示',msg) {
    Modal.error({
        title: title,
        content: msg,
    });
};

export let ErrorModalAutoDismiss = function (msg,disSec = 1000) {
    const  modal = Modal.error({
        title: '提示',
        content: msg,
    });

    setTimeout(()=> modal.destroy(),disSec);
};

export let SuccessModal = function (msg) {
    Modal.success({
        title: '恭喜',
        content: msg,
    });
};

export let InfoModal = function (obj) {

    /**
     * {
        title: 'This is a notification message',
        content: (
         <div>
         <p>some messages...some messages...</p>
            <p>some messages...some messages...</p>
        </div>
        ),
        onOk() {},
  }
     * */
    Modal.info(obj);
};

export let ShowConfirmModal = function (obj) {
    /**
     *     {
        title: 'Are you sure delete this task?',
            content: 'Some descriptions',
        okText: 'Yes',
        okType: 'danger',
        cancelText: 'No',
        onOk() {
        console.log('OK');
     },
        onCancel() {
        console.log('Cancel');
        },
        }
     * */

    confirm(obj);
};

export let CommonModal = function (obj,type) {
    if (type === 'error'){
        Modal.error(obj);
    }else if(type === 'success'){
        Modal.success(obj);
    }else if(type === 'info'){
        Modal.info(obj);
    }else if(type === 'confirm'){
        confirm(obj);
    }else {

    }
}